package ca.jacobk.foodspin;

import java.util.Timer;
import java.util.TimerTask;

import ca.jacobk.math.WheelTicker;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class FoodSpinActivity extends Activity {
	WheelTicker ticker = new WheelTicker();
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	setContentView(R.layout.main);
    	WheelSurfaceView view = (WheelSurfaceView)findViewById(R.id.glView);
    	WheelRenderer renderer = new WheelRenderer();
    	view.setRenderer(renderer);
    	
    	Timer wheelTimer = new Timer();
    	
    	wheelTimer.scheduleAtFixedRate(spinTask, 50, 50);
    	ticker.setExtraSpins(6);
    	ticker.setGoalSegment(10, 4);
    }
    
    private TimerTask spinTask = new TimerTask() {
		
		@Override
		public void run() {
			ticker.tick();
			Log.d("Tick", "rotation: " + ticker.getRotation());
			if(ticker.getRotation() <=0 )
				this.cancel();
		}
	};
    
    
}
